package util;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ProtocolProcesser {
	private static ObjectMapper mapper=new ObjectMapper();
	public String stringifyRes(Respack pack){
		String line=null;
		try {
			line=mapper.writeValueAsString(pack);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return line;
	}
	public static Reqpack parseResline(String line){
		Reqpack pack=null;
		try {
			pack=mapper.readValue(line, Reqpack.class);
		} catch (JsonParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return pack;
	}
	
}
